<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<%
	String context = request.getContextPath();
	
	String queryExpression = (String)request.getAttribute("queryExpression");
	if(queryExpression == null) queryExpression = "";

	UserDocument userDoc = (UserDocument)request.getAttribute("userDoc");
	if(userDoc == null) userDoc = new UserDocument();
	
	String actionType = (String)request.getAttribute("actionType");
	
	String flag = (String)request.getAttribute("flag");
	if(flag == null) flag = "";
	
	String editPath = context + EditConfigUtil.getEditPath();
	
	int size = 85;
	int tdHeight = 30;
	int cols = 65;
	int rows = 6;

%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>

<%@page import="component.fulltextsearch.entity.UserDocument"%>
<%@page import="component.fulltextsearch.util.SearchConfigUtil"%>


<%@page import="component.edit.util.EditConfigUtil"%><head>
	<link type="text/css" rel="stylesheet" href="<%=editPath%>/css/edit.css" />
	<script src="<%=editPath%>/js/EditUtil.js"></script>
</head>

<body>

<form action="<%=SearchConfigUtil.getSearchUrl()%>" method="post">
	
	<input type="hidden" name="queryExpression" value="<%=queryExpression%>">
	
	<input type="hidden" id=-"keyValue" name="keyValue" value="<%=userDoc.getKeyValue()%>">

	<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#BBBDC9">
		<tr>
			<td valign="top" bgcolor="#FFFFFF">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
			
				<!-- 标题栏开始 -->
				<tr class="table_backgroud_9">
					<td height="33" colspan="2">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="50%" align="center">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td width="18%" align="center">
											<img id="opt_img" src="<%=editPath%>/image/add.gif" width="16" height="16" />
										</td>
										<td width="82%" align="left" class="font_black"><span id="opt_context">新增</span></td>
									</tr>
								</table>
								<SCRIPT LANGUAGE="JavaScript">
								<!--

									if(document.getElementById("keyValue").value) {
										document.getElementById("opt_img").src="<%=editPath%>/image/edit.gif";
										document.getElementById("opt_context").innerHTML="修改";
									} else {
										document.getElementById("opt_context").src="<%=editPath%>/image/add.gif";
										document.getElementById("opt_context").innerHTML="新增";
									}
	
								//-->
								</SCRIPT>
							</td>
							<td width="75%">&nbsp;</td>
						</tr>
					</table>
					</td>
				</tr>
				<!-- 标题栏结束 -->
				
				<!-- 数据展现开始 -->
				<tr>
					<td width="90%" align="center" bgcolor="#F5F8FD" valign="top">
					<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="F5F8FD">

						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-two">关键值：&nbsp;&nbsp;</span>
							</td>
							<td>
								<input type="text" id="keyValue" name="vo.keyValue" value="<%=userDoc.getKeyValue()%>" oldValue="<%=userDoc.getKeyValue()%>" class="input_content" size="<%=size%>" maxlength="50" validatetype="require" msg="" readonly="readonly" />
							</td>
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-one">标题：&nbsp;&nbsp;</span>
							</td>
							<td>
								<input type="text" id="name" name="vo.name" value="<%=userDoc.getName()%>" oldValue="<%=userDoc.getName()%>" class="input_content" size="<%=size%>" maxlength="50" validatetype="require" msg="标题不能为空" />
							</td>	
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-one">关键字：&nbsp;&nbsp;</span>
							</td>
							<td>
								<input type="text" id="keywords" name="vo.keywords" value="<%=userDoc.getKeywords()%>" oldValue="<%=userDoc.getKeywords()%>" class="input_content" size="<%=size%>" maxlength="100" validatetype="require" msg="关键字不能为空" />
							</td>
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-one">分类：&nbsp;&nbsp;</span>
							</td>
							<td>
								<select id="typeCode" name="vo.typeCode">
									<option value="java">java</option>
									<option value="db2">db2</option>
									<option value="tomcat">tomcat</option>
								</select>
							</td>	
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-one">创建时间：&nbsp;&nbsp;</span>
							</td>
							<td>
								<input type="text" id="createTime" name="vo.createTime" value="<%=userDoc.getCreateTimeStr()%>" oldValue="<%=userDoc.getCreateTimeStr()%>" class="input_content" size="<%=size%>" maxlength="" validatetype="date" msg="" readonly="readonly"/>
							</td>	
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-two">用户：&nbsp;&nbsp;</span>
							</td>
							<td>
								<input type="text" id="rightUsers" name="vo.rightUsers" value="<%=userDoc.getRightUsers()%>" oldValue="<%=userDoc.getRightUsers()%>" class="input_content" size="<%=size%>" maxlength="100" validatetype="" msg="" />
							</td>	
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-two">角色：&nbsp;&nbsp;</span>
							</td>
							<td>
								<input type="text" id="rightRoles" name="vo.rightRoles" value="<%=userDoc.getRightRoles()%>" oldValue="<%=userDoc.getRightRoles()%>" class="input_content" size="<%=size%>" maxlength="100" validatetype="" msg="" />
							</td>	
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-two">是否可删除：&nbsp;&nbsp;</span>
							</td>
							<td>
								<input type="checkbox" name="vo.isDelete" value="true" checked="checked" onclick="doOnClick(this)"/>
							</td>	
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-two">摘要：&nbsp;&nbsp;<br>(最多只能输入<span style='color:red' id='summaryArea' >50</span>个字)&nbsp;&nbsp;</span>
							</td>
							<td>
								<textarea id="summary" name="vo.summary" oldValue="" cols="<%=cols%>" rows="<%=rows%>" class="input_content" validatetype="" msg="" onblur="editUtil.checkTextAreaValueLen(this,'summaryArea',50)" onkeyup="editUtil.checkTextAreaValueLen(this,'summaryArea',50)">
								<%=userDoc.getSummary()%>
								</textarea>
							</td>
						</tr>
						
						<tr>
							<td width="18%" height="<%=tdHeight%>" class="input-title">
								<span class="input-normal-two">内容：&nbsp;&nbsp;<br>(最多只能输入<span style='color:red' id='contentArea' >50</span>个字)&nbsp;&nbsp;</span>
							</td>
							<td>
								<textarea id="content" name="vo.content" oldValue="" cols="<%=cols%>" rows="<%=rows%>"  class="input_content" validatetype="" msg="" onblur="editUtil.checkTextAreaValueLen(this,'contentArea',50)" onkeyup="editUtil.checkTextAreaValueLen(this,'contentArea',50)">
								<%=userDoc.getContent()%>
								</textarea>
							</td>
						</tr>
						
					</table>
					</td>
				</tr>
				<!-- 数据展现结束 -->
				
				<!-- 按钮栏开始 -->
				<tr>
					<td height="41" align="center" class="table_backgroud_2">
					<table width="60%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td width="13%" height="40" align="right" valign="top">
								<img src="<%=editPath%>/image/e1_46.jpg" width="31" height="40" />
							</td>
							<td width="82%" align="center" valign="middle" class="page_backgroud">
							<table width="84%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<!-- 第一个按钮 -->
									<%if("add".equals(actionType)){%>
									<td align="center">
									<table border="0" cellspacing="0" cellpadding="0"
										class="button_img_4" onMouseOver="this.style.cursor='pointer'"
										onClick="editUtil.doSaveAndAdd()">
										<tr>
											<td align="center" valign="middle">保存并新增</td>
										</tr>
									</table>
									</td>
									<%}%>
									
									<!-- 第二个按钮 -->
									<td align="center">
									<table width="65" border="0" cellpadding="0" cellspacing="0"
										onClick="editUtil.doSaveAndExit()"
										onMouseOver="this.style.cursor='pointer'" class="button_img_4">
										<tr>
											<td align="center" valign="middle">保存后返回</td>
										</tr>
									</table>
									</td>
									
									<!-- 第三个按钮 -->
									<td align="center">
									<table width="65" border="0" cellpadding="0" cellspacing="0"
										onClick="editUtil.doReturn()"
										onMouseOver="this.style.cursor='pointer'" class="button_img_2">
										<tr>
											<td align="center" valign="middle">返回</td>
										</tr>
									</table>
									</td>
								</tr>
							</table>
							</td>
							<td width="5%" align="left" valign="top"><img
								src="<%=editPath%>/image/e3_49.jpg" width="28" height="40" />
							</td>
						</tr>
					</table>
					</td>
				</tr>
				<!-- 按钮栏结束 -->
				
			</table>
			</td>
		</tr>
	</table>
</form>

</body>

<script>

	function doOnClick(obj){
		//alert(obj.checked);
		if(obj.checked == true){
			obj.value = "true";
		}else{
			obj.value = "false";
		}
	}

	var editUtil = new EditUtil("<%=context%>","<%= SearchConfigUtil.getSearchUrl()%>");

	window.onload = function(){
		var flag = "<%=flag%>";
		if("doSaveAndAdd" == flag){//保存并新增
			opener.document.forms[0].submit();
			window.focus();
		}else if("doSaveAndExit" == flag){//保存后返回
			opener.document.forms[0].submit();
			window.close();
		}
		
		editUtil.loadCheckTextAreaValueLen("summary","summaryArea",50);
		editUtil.loadCheckTextAreaValueLen("content","contentArea",50);
	}
	
</script>
